#ifndef __INFORMATION_H__
#define __INFORMATION_H__
#include "Sprites.h"
#include "d3d9.h"
#include "d3dx9.h"
#include "windows.h"

#define APP_TITILE "MARIO C_A_P CNPM 03 UIT"
#define APP_CLASS "MARIO"

#define WINDOW_WIDTH 800
#define WINDOW_HEIGHT 600

#define FRAME_RATE 60


#define NUMBER_WIDTH 15;
#define NUBER_HEGHT  20;

#define SIZE_CELL 30
#define INFO_IMAGE "Images\\Info.png";

class Infomation
{
private:

	LPDIRECT3DTEXTURE9 Info_Image;
private:
	   void DrawNumber(int x,int y,int number)
	   {
		   number;
		   int Count=0;
		   D3DXVECTOR3 des(x,y,0);
		   if(number==0)
		   {
			   RECT r;
			   r.left=0;r.right=r.left+NUMBER_WIDTH;
			   r.top=20;r.bottom=r.top+NUBER_HEGHT;
			   CSprites::_spriteHandler->Draw(Info_Image,&r,NULL,&des,D3DCOLOR_XRGB(255,255,255));
		   }
		   while(number>0)
		   {
			   int digit=number%10;
			   RECT r;
			   r.left=digit*NUMBER_WIDTH;r.right=r.left+NUMBER_WIDTH;
			   r.top=20;r.bottom=r.top+NUBER_HEGHT;
			   des.x=x-15*Count;des.y=y,des.z=0;
			   CSprites::_spriteHandler->Draw(Info_Image,&r,NULL,&des,D3DCOLOR_XRGB(255,255,255));
			   Count++;
			   number=number/10;
		   }
	   }
public:
	int CointCounter,Life,World;
	int time ,time1;
	DWORD now, now1 ;
	Infomation(int life, int counter, int world)
	{
		now== GetTickCount();
		time=600;
		World=world;
		time1=3;
		Life=life;
		CointCounter=counter;
		Info_Image=CSprites::LoadTexture("Images\\Info.png",0);
	}
	void Draw()
	{
		CSprites::_spriteHandler->Begin(D3DXSPRITE_ALPHABLEND);
		RECT r;
		//
		r.left=0;r.top=0;r.right=100;r.bottom=r.top+20;

		D3DXVECTOR3 des;
		des.x=20;
		des.y=10;des.z=0;
		CSprites::_spriteHandler->Draw(Info_Image,&r,NULL,&des,D3DCOLOR_XRGB(255,255,255));
		DrawNumber(140,10,Life);
		//
		r.left=120;r.top=0;r.right=150;r.bottom=r.top+20;
		des.x=220;des.y=10,des.z=0;
		CSprites::_spriteHandler->Draw(Info_Image,&r,NULL,&des,D3DCOLOR_XRGB(255,255,255));
		DrawNumber(300,10,CointCounter);

		r.left=0;r.top=100;r.right=100;r.bottom=r.top+20;
		des.x=380;
		des.y=10;des.z=0;
		CSprites::_spriteHandler->Draw(Info_Image,&r,NULL,&des,D3DCOLOR_XRGB(255,255,255));
		DrawNumber(480,11,World);

		r.left=100;r.top=100;r.right=200;r.bottom=r.top+20;
		des.x=550;
		des.y=10;des.z=0;
		CSprites::_spriteHandler->Draw(Info_Image,&r,NULL,&des,D3DCOLOR_XRGB(255,255,255));
		DrawNumber(700,11, time);
		if(GetTickCount()-now>=1000)
		{
			time--;
			now=GetTickCount();
		}
		
		if(World==0&&time1>0)
		{
			r.left=0;r.top=100;r.right=100;r.bottom=r.top+20;
			des.x=300;
			des.y=320;des.z=0;
			CSprites::_spriteHandler->Draw(Info_Image,&r,NULL,&des,D3DCOLOR_XRGB(255,255,255));
			DrawNumber(400,320,3);
			r.left=0;r.top=100;r.right=100;r.bottom=r.top+20;
			des.x=480;
			des.y=320;des.z=0;
			CSprites::_spriteHandler->Draw(Info_Image,&r,NULL,&des,D3DCOLOR_XRGB(255,255,255));
			DrawNumber(580,320,2);
			r.left=0;r.top=100;r.right=100;r.bottom=r.top+20;
			des.x=680;
			des.y=320;des.z=0;
			CSprites::_spriteHandler->Draw(Info_Image,&r,NULL,&des,D3DCOLOR_XRGB(255,255,255));
			DrawNumber(780,320,1);
			if(GetTickCount()-now1>=1000)
			{
				time1--;
				now1=GetTickCount();
			}
		}
		CSprites::_spriteHandler->End();
	}
	void DrawGameOver()
	{
		RECT r;
		r.left=0;r.top=40;r.right=200;r.bottom=90;
		D3DXVECTOR3 des;
		des.x=300;des.y=250,des.z=0;
		CSprites::_spriteHandler->Begin(D3DXSPRITE_ALPHABLEND);
		CSprites::_spriteHandler->Draw(Info_Image,&r,NULL,&des,D3DCOLOR_XRGB(255,255,255));
		DrawNumber(270,10,CointCounter);
		CSprites::_spriteHandler->End();
	}

	void Reset()
	{
		Life=3;
		CointCounter=0;
	}
};
#endif